<?php
class Part {
	public $id;
	public $price;
	public $correctionmultiplier;
	public $quantity;
	public function IsValid(){
		return !is_null($this->price) && is_numeric($this->price) && !is_null($this->correctionmultiplier) && is_numeric($this->correctionmultiplier) && !is_null($this->quantity) &&is_numeric($this->quantity); 
	}
	public function UpdateInSQL($id, $price, $correctionmultiplier){
		if ( !is_null ($price) && is_numeric($price) && !is_null ($correctionmultiplier) && is_numeric($correctionmultiplier) )	
		{
			require_once("./includes/interface.SQL.inc.php");
			require_once("./includes/class.MySQL.inc.php");
			$sql = new MySQL("localhost", "szofttech", "alma");
			//$sql->ConnectionTest();
			$sql->select_db("szofttech");
			$query= "UPDATE part SET price='".$price."', correctionmultiplier='".$correctionmultiplier."' WHERE id = '".$id."';";
			$sql->query($query) or die($sql->Error());		
		} else {
			//TODO
		}
			
	}
	public function GetPrice(){
		if ( $this->IsValid() )
		{
			return $this->quantity * $this->price * $this->correctionmultiplier;
		}
		else {
			Throw new Exception("Valami szar");
		}
		
	}
}
?>